import baseApi from '@/config/server/api/base.js'
import tool from '@/common/tool'
//创建消息
function msgInsert(params) {
  return baseApi.message.msgInsert.fetch(params).then(res => {
    return res
  })
}
//消息分页列表查询
function msgFindPages(params) {
  return baseApi.message.msgFindPages.fetch(params).then(res => {
    res.list && res.list.forEach(item => {
      item.peopleAll = `${item.totalPeople?item.totalPeople:'0'}/${item.readPeople?item.readPeople:'0'}/${item.unreadPeople?item.unreadPeople:'0'}`
      item.sendCompanyAnduserName = item.sendCompany == '00' ? '全员' : item.sendCompany
      item.sendFlagTxt = item.sendFlag ? item.sendFlag == '1' ? '实时' : item.sendFlag == '2' ? '定时' : '-' : '-'
    });
    return res
  })
}
//消息阅读明细(公司下的全部案场)
function getMessageReadingDetails(params) {
  return baseApi.message.getMessageReadingDetails.fetch(params)
}
//消息阅读明细(导出Excel到下载中心)
function exportMessage(params) {
  console.log(params)
  return baseApi.message.exportMessage.fetch(params)
}
//消息详情
function getMessageDetails(params) {
  return baseApi.message.getMessageDetails.fetch(params)
}
//消息详情修改
function updateMsg(params) {
  return baseApi.message.updateMsg.fetch(params)
}
//列表发送/重新发送
function sendMsg(params) {
  return baseApi.message.sendMsg.fetch(params)
}
export default {
  msgInsert,
  msgFindPages,
  getMessageReadingDetails,
  exportMessage,
  getMessageDetails,
  updateMsg,
  sendMsg
}